package com.jfs.utils;

import cn.hutool.core.date.DateUtil;
import com.jfs.entity.Device;
import com.jfs.envent.entity.BaseEventEntity;

/**
 * @Description 创建设备基础信息对象工具类
 * @E-mail cwm3412638@163.com
 * @Author cwm
 * @Date 2022/8/2
 */
public class DeviceUtil {
    /**
     * 创建设备基础信息
     *
     * @param event
     * @return
     */
    public static Device createBaseDevice(BaseEventEntity event) {
        //插入设备信息
        Device registerDevice = new Device();
        //设备id
        registerDevice.setDeviceId(event.getDeviceID());
        //设置设备状态
        registerDevice.setOnline(true);
        //创建时间
        registerDevice.setCreateTime(DateUtil.date());
        //注册时间
        registerDevice.setRegisterTime(DateUtil.date());
        //ip
        registerDevice.setIp(event.getIp());
        //端口
        registerDevice.setPort(event.getPort());
        //此处为了设备注册还没有发送心跳会检测不到问题
        registerDevice.setKeepaliveTime(DateUtil.date());
        return registerDevice;
    }
}
